<?php

/* init.php
 * sets various config variables and error reporting
 */

error_reporting(E_ALL);
date_default_timezone_set("Europe/London");
ini_set('display_errors', '1');

$GLOBALS['FILE_SYSTEM_ROOT'] = dirname(dirname(__FILE__));

//echo  $GLOBALS['FILE_SYSTEM_ROOT'];

// get config info
$xml = simplexml_load_file($GLOBALS['FILE_SYSTEM_ROOT']."/config/config.xml");
if(!isset($xml))echo "$xml not set";

$PathsXML = $xml->Paths;
$GLOBALS['DOCUMENT_ROOT'] = $PathsXML->DocumentRoot;

//echo $PathsXML->DocumentRoot."\n";

//echo $GLOBALS['DOCUMENT_ROOT']."\n";

require_once($GLOBALS['FILE_SYSTEM_ROOT']."/model/classes/database/Database.php");
if(!isset($xml->Database))echo "$xml->Database not set";
$databaseXML = $xml->Database;
$GLOBALS['DATABASE'] = new Database($databaseXML->Server,$databaseXML->Database,$databaseXML->Username,$databaseXML->Password);
//echo $GLOBALS['DATABASE']->getDatabaseName()."\n";
require_once($GLOBALS['FILE_SYSTEM_ROOT']."/model/classes/events/SNAPEvent.php");
require_once($GLOBALS['FILE_SYSTEM_ROOT']."/../MSWebGUI/Mail/Message.php");

require_once($GLOBALS['FILE_SYSTEM_ROOT']."/model/classes/utilities/Users.php");
$users = new Users();
$GLOBALS['USERS'] = $users->getUsers();

require_once($GLOBALS['FILE_SYSTEM_ROOT']."/model/classes/utilities/User.php");


$userObjects = array();
foreach ($GLOBALS['USERS'] as $user)
{
	$userobj = new User($user['SnapUserID']);
	array_push($userObjects,$userobj);
}
$GLOBALS['USEROBJECTS'] = $userObjects;


require_once($GLOBALS['FILE_SYSTEM_ROOT']."/model/classes/utilities/UserGroups.php");
$usergroups = new UserGroups();
$GLOBALS['USERGROUPS'] = $usergroups->getGroups();

require_once($GLOBALS['FILE_SYSTEM_ROOT']."/model/classes/utilities/UserEmails.php");
$useremails = new UserEmails();
$GLOBALS['USEREMAILS'] = $useremails->getUsers();

require_once($GLOBALS['FILE_SYSTEM_ROOT']."/model/classes/utilities/Locations.php");
$locations = new Locations();
$GLOBALS['LOCATIONS'] = $locations->getLocations();

require_once($GLOBALS['FILE_SYSTEM_ROOT']."/model/classes/utilities/Involvees.php");
$involvees = new Involvees();
$GLOBALS['INVOLVEES'] = $involvees->getInvolvees();

require_once($GLOBALS['FILE_SYSTEM_ROOT']."/model/classes/utilities/EventTypes.php");
$eventTypes = new EventTypes();
$GLOBALS['EVENTTYPES'] = $eventTypes->getEventTypes();

require_once($GLOBALS['FILE_SYSTEM_ROOT']."/model/classes/utilities/Sessions.php");
$sessions = new Sessions();
$GLOBALS['SESSIONS'] = $sessions->getSessions();











